package com.nf.action;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class Dog {

    //目的：用于定于那些类，那些方法要有狗跟踪，那些类，那些方法不允许狗的靠近
    @Pointcut("execution(* com.nf.action.*.kk(..))")
    public void m1(){}

    @Around("m1()")
    public Object around(ProceedingJoinPoint pjp) throws Throwable {
        System.out.println("连接点JoinPoint："+pjp);
        Object result = pjp.proceed();
        System.out.println("主人的返回结果是："+result);
        return result;
    }

    /*
    @AfterReturning("m1()")
    public Object ok(){
        System.out.println("恭喜主人，一切正常");
        return null;
    }

    @AfterThrowing("m1()")
    public Object error(){
        System.out.println("主人请注意，隔壁老王就在衣柜里面");
        return null;
    }
*/
    /*
    @After("m1()")
    public Object saybay(){
        System.out.println("主人你放心走吧，我留下");
        return null;
    }

    @Before("m1()")
    public Object sayhello(){
        System.out.println("主人你好，我是小狗");
        return null;
    }
    */
}
